package com.verlet.gateway.filter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * 不需要配置文件中配置, 系统初始化时加载, 作用在所有的路 由上
 * 最终通过GatewayFilterAdapter包装成GatewayFilterChain可识别的过滤器
 *
 * @author verlet
 */
@Slf4j
@Component
public class AuthorizeGlobalFilter implements GlobalFilter, Ordered {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        log.info("========>全局自定义过滤器========");
        return chain.filter(exchange);
    }

    @Override
    public int getOrder() {
        return 0;
    }
}
